package org.hawk.gwt.ppc.parser.impl;

import org.hawk.gwt.ppc.parser.Descriptor;
import org.hawk.gwt.ppc.parser.Token;
import org.hawk.gwt.ppc.utils.PreprocessorException;

/**
 * This interface represents parser that is bind to specific
 * {@link DescriptorType} so that parsing logic is split
 * between different classes and more structurized.
 * 
 * @author alex.bereznevatiy@gmail.com
 *
 */
interface DescriptorParser {
	
	/**
	 * @param token
	 * @return <code>true</code> if descriptor represented by this
	 * parser can start from passed token. 
	 */
	boolean accepts(Token token);
	
	/**
	 * Parses descriptor started from current token. 
	 * @param parser root
	 * @param tokenizer associated with this parser
	 * @param params additional parameters to parser if any
	 * @return parsed descriptor
	 * @throws PreprocessorException in case of troubles
	 */
	Descriptor parse(TokenBasedJavaParser parser, TokenSource tokenizer, Object...params) throws PreprocessorException;
}
